import UserModel from "../../../../models/User";

const userModel = new UserModel()

Page({
  data: {},
  onLoad: function (options) {

  },

  /*
    点击 "拒绝" 返回到首页
    如果是在获取的时候, 点击微信中的 "拒绝", 数据库会删除openid
   */
  onDeny() {
    wx.redirectTo({
      url: '/pages/home/index'
    })
  },

  getPhoneNumber(e) {
    const detail = e.detail
    userModel.saveMobile({ data: detail.encryptedData, iv: detail.iv, session_key: userModel.getSessionKey() }).then(() => {
      wx.switchTab({
        url: '/pages/center/index'
      })
    })
  }
});
